package ru.narod.amidoriya.app.sushibaramidoriya;


	import java.io.File;
	import org.xmlpull.v1.XmlPullParser;
	import org.xmlpull.v1.XmlPullParserFactory;
	import android.R.*;

import android.annotation.SuppressLint;
	import android.app.AlertDialog;
	import android.content.DialogInterface;
	import android.content.Intent;
	import android.content.DialogInterface.OnClickListener;
	import android.os.Bundle;
	import android.os.Environment;
	import android.preference.EditTextPreference;
	import android.preference.PreferenceActivity;
	import android.view.Menu;
import android.view.MenuItem;
	
	@SuppressLint("NewApi")
	public class PreferAmidoriya extends PreferenceActivity { 
		EditTextPreference prisepath;
		public static File EDIR = Environment.getExternalStorageDirectory();
		@SuppressLint("NewApi")
		@Override 
		protected void onCreate(Bundle savedInstanceState) {
			getActionBar().setDisplayHomeAsUpEnabled(true);
			super.onCreate(savedInstanceState);
			addPreferencesFromResource(R.xml.prefappamidoriya);
		} 

		public boolean onCreateOptionsMenu(Menu menu) { 

			getMenuInflater().inflate(R.menu.pmenu, menu);

			return true;

		}

		@Override
		public boolean onPrepareOptionsMenu(Menu menu) {

			menu.findItem(R.id.loaditem1).setEnabled(true);
			menu.findItem(R.id.pitem2).setEnabled(true);
			menu.findItem(R.id.abitem3).setEnabled(true);
			return super.onPrepareOptionsMenu(menu);
		}

		@Override
		public boolean onOptionsItemSelected(MenuItem item) {

			switch (item.getItemId()) {
			
			case android.R.id.home:
				finish();			
				break;
			
			case R.id.loaditem1: 
				GoMain();
				break; 
			case R.id.pitem2:
				//���������
				setResult(5);
				finish();
				break; 
			case R.id.abitem3: 
				//� ���������
				setResult(10);
				finish();


				break;
			}       


			return super.onOptionsItemSelected(item); 

		} 
		private void GoMain() {
			AlertDialog.Builder buildergomain = new AlertDialog.Builder(this);
			buildergomain.setTitle(R.string.lt_app);		
			buildergomain.setMessage(R.string.lmmm_app);		
			buildergomain.setNegativeButton(R.string.qn_app, null);
			buildergomain.setPositiveButton(R.string.qy_app, new OnClickListener() {
				public void onClick(DialogInterface arg0, int arg1) {
					setResult(7);
					finish(); 	            	

				}
			}).create().show();	
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);

			if (resultCode == 7) {
				setResult(7);
				finish();
			}
			//����� ��� �� �������� �������� � � ���������
			if (resultCode ==  5) {
				try {
					openOptionsMenu();
				} catch (Exception e) {

				}
			} 

		}

	}

